<template>
  <el-dialog
    v-model="dialogVisible"
    class="app-dialog"
    :show-close="false"
    :destroy-on-close="true"
    align-center
    append-to-body
    width="360"
  >
    <template #header>
      <div class="app-dialog-header">
        <span class="title">{{ props.title }}</span>
        <div class="close" @click="dialogVisible = false">
          <svgIcon name="close" />
        </div>
      </div>
    </template>
    <div class="confirm-content">{{ props.content }}</div>
    <template #footer>
      <div class="dialog-footer">
        <div class="app-button-info cancel" @click="dialogVisible = false">取消</div>
        <div class="app-button-primary confirm" @click="confirm">确认</div>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ElDialog } from "element-plus";
import { ref, computed } from "vue";

const props = defineProps({
  modelValue: {
    type: Boolean,
    required: true
  },
  title: {
    type: String,
    default: "确认"
  },
  content: {
    type: String,
    default: ""
  }
});
const emit = defineEmits(["update:modelValue", "confirm"]);
const dialogVisible = computed({
  get: () => {
    return props.modelValue;
  },
  set: val => {
    emit("update:modelValue", val);
  }
});

// 确认
function confirm() {
  emit("confirm");
}
</script>

<style scoped lang="scss">
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  .cancel {
    width: 148px;
  }
  .confirm {
    width: 148px;
  }
}
.confirm-content {
  padding-top: 30px;
  padding-bottom: 42px;
  font-size: 14px;
  font-weight: 400;
  line-height: 28px;
  color: #717681;
  text-align: center;
}
</style>
